package com.nlp.visualization.dao.impl.backend;

import com.nlp.visualization.dao.backend.IModelDao;
import com.nlp.visualization.dao.base.DaoSupportImpl;
import com.nlp.visualization.pojo.db.TModel;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author LXM
 * @Title: NLPVisualizationTools
 * @Description:
 * @date 2018/5/10下午9:30
 */
@Repository
public class ModelDaoImpl extends DaoSupportImpl<TModel> implements IModelDao {
    @Override
    public int count(String modelType) {

        String hql = "select count(*) from " + clazz.getName() + " WHERE description like '%" + modelType + "%'";
        System.out.println(hql);
        int maxValue = Integer.parseInt(getSession().createQuery(hql).uniqueResult() + "");
        return maxValue;
    }

    @Override
    public List findByType(String keyword) {

        String hql = "SELECT t FROM TModel t WHERE t.description like '%" + keyword + "%'";
        return getSession().createQuery(hql).list();
    }
}
